#include<bits/stdc++.h>
#define int long long
using namespace std;

const int N  = 100005;

struct car{
    int d,ini,a;
}arr[N];

bool cmp(car x,car y){
    return x.d < y.d;
}

int n,m,l,v;
int dtcr[N];

void solve(){
    cin >> n >> m >> l >> v;
    for(int i=1;i<=n;i++){
        cin >> arr[i].d >> arr[i].ini >> arr[i].a;
    }
    for(int i=1;i<=m;i++){
        cin >> dtcr[i];
    }
    sort(dtcr+1,dtcr+m+1);
    sort(arr+1,arr+n+1,cmp);
    int cnt = 0;
    int mini = -999999;
    for(int i=1;i<=n;i++){
        if(arr[i].d > dtcr[m]){
            continue;
        }else{
            if(arr[i].ini > v){
                cnt++;
            }
            mini = max(mini,arr[i].d);
        }
    }
    cout << cnt << " ";
    if(cnt == 0){
        cout << m << endl;
        return;
    }
    for(int i=m-1;i>=1;i--){
        if(dtcr[i] < mini && dtcr[i+1] >= mini){
            cout << i << endl;
            return;
        }
    }
}

signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T;
    cin >> T;
    while(T--)solve();
    return 0;
}
